package com.jstyle.beatecg.daoManager;

import android.text.TextUtils;

import com.jstyle.beatecg.dao.DbManager;
import com.jstyle.beatecg.dao.HrvDataDao;
import com.jstyle.beatecg.model.HrvData;

import org.greenrobot.greendao.query.QueryBuilder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2018/6/5.
 */

public class HrvDataDaoManager {
    public static void insertHrvData(HrvData hrvData){
        DbManager.getInstance().getDaoSession().getHrvDataDao().insertOrReplace(hrvData);
    }

    public static void DeleteALL(){
        DbManager.getInstance().getDaoSession().getHrvDataDao().deleteAll();
    }

    public static List<HrvData> getHrvData(String startDate,String endDate){
        List<HrvData> hrvDataList=new ArrayList<>();
        QueryBuilder<HrvData> queryBuilder= DbManager.getInstance().getDaoSession().getHrvDataDao().queryBuilder();
        hrvDataList= queryBuilder.where(HrvDataDao.Properties.Time.between(startDate+" 00:00:00",endDate+" 23:59:00")).orderAsc(HrvDataDao.Properties.Time).list();
        return hrvDataList;
    }
    public static List<HrvData> getAllHrvData(){

        QueryBuilder<HrvData> queryBuilder= DbManager.getInstance().getDaoSession().getHrvDataDao().queryBuilder();
        return queryBuilder.list();
    }


    public static HrvData HrvData(String TIME){
        QueryBuilder<HrvData> queryBuilder= DbManager.getInstance().getDaoSession().getHrvDataDao().queryBuilder();
        return queryBuilder.where(HrvDataDao.Properties.Time.eq(TIME)).orderAsc(HrvDataDao.Properties.Time).unique();
    }
}
